<template>
  <hose>
    <Search :iptObj="iptObj" :optionArr="optionArr"></Search>
    <Table
      :tableArr="tabArr"
      :operationObj="operationObj"
      :tableData="tableData"
      @click="deleteRow1()"
    ></Table>
    <PaginationVue @cChange="fun" :total="total"></PaginationVue>
  </hose>
</template>

<script setup>
import hose from "../../components/hose.vue";
import Search from "../../components/Search.vue";
import Table from "../../components/Table.vue";
import ReceivingVue from "../../components/Receiving.vue";
import { useRouter } from "vue-router";
import { ref, reactive } from "vue";
import { getaccount } from "../../api/index";
import PaginationVue from "../../components/Pagination.vue";

const router = useRouter();

const total = ref(3000);
const num = ref(1);
const arr = ref([]);

const status = ref("");
getaccount(num.value, localStorage.token, 10).then(res => {
  arr.value = res.data.data.data;

  total.value = res.data.data.totalPages * 10;
  tableData.value = [];
  arr.value.forEach(item => {
    tableData.value.push({
      订单编号: item.accountId,
      订单类型: item.orderType,
      订单时间: item.time,
      收入币: item.income,
      支出币: item.expend,
      状态: item.status
    });
  });
});

const fun = index => {
  num.value = index;
  getaccount(num.value, localStorage.token, 10).then(res => {
    arr.value = res.data.data.data;

    total.value = res.data.data.totalPages * 10;
    tableData.value = [];
    arr.value.forEach(item => {
      tableData.value.push({
        订单编号: item.accountId,
        订单类型: item.orderType,
        订单时间: item.time,
        收入币: item.income,
        支出币: item.expend,
        状态: item.status
      });
    });
  });
};

const tabArr = reactive({
  订单编号: "订单编号",
  订单类型: "订单类型",
  订单时间: "订单时间",
  收入币: "收入币",
  支出币: "支出币",
  状态: "状态"
});
const tableData = ref([]);

const operationObj = ref({
  operation1: "查看",
  operation2: "接单",
  title1: "状态", //操作标题
  title2: "操作2",
  type1: "primary", //button 类型
  type2: "primary",
  text1: true, // true 为文字类型
  text2: false,
  bool1: true, //操作是否显示
  bool2: false
});
const iptObj = ref({
  title: "钱包管理",
  userBool: true,
  userTitle: "订单编号",
  userTel: "联系电话",
  userRegion: "当前状态",
  telrBool: false,
  regionBool: true,
  userText: "请输入订单编号",
  telText: "请输入联系电话",
  regionText: "请选择内容",
  BtnBool: true
});
const optionArr = ref(["所有", "回收订单", "送货订单", "充值订单"]);

const deleteRow1 = () => {
  router.push("/Recharge/admin");
};
</script>

<style lang="less" scoped></style>
